package com.xdqzy.baseline.common.utils;

import org.springframework.context.ApplicationContext;

import java.util.Locale;

/**
 * @author : qss
 * @version V1.0
 * @Title : 接口响应结果包装
 * @ClassName: com.xdqzy.baseline.common.model.GlobalResponseHandler.java
 * @Description:
 * @date :  2020-10-20 17:49
 */
public class ResourceUtil {

    /**
     * Spring上下文
     */
    private static ApplicationContext context = SpringContextHelper.getApplicationContext();

    /**
     *
     * Description: 根据错误码获取错误信息<br>
     *
     * @param msgKey <br>
     * @param args <br>
     * @return <br>
     */
    public static String getMessage(String msgKey, Object... args) {
        return context.getMessage(msgKey, args, msgKey, Locale.CHINA);
    }

    /**
     *
     * Description: 根据错误码获取错误信息<br>
     *
     * @param msgKey <br>
     * @param locale 语音类型<br>
     * @param args <br>
     * @return <br>
     */
    public static String getMessage(String msgKey, Locale locale, Object... args) {
        return context.getMessage(msgKey, args, msgKey, locale);
    }
}
